home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / AIncludes / OSUtils.a < prev    next >
Encoding:
Text File  |  1998-08-17  |  12.1 KB  |  499 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        OSUtils.a
  3. ;
  4. ;    Contains:    OS Utilities Interfaces.
  5. ;
  6. ;    Version:    Technology:    Mac OS 8
  7. ;                Release:    Universal Interfaces 3.2
  8. ;
  9. ;    Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10. ;
  11. ;    Bugs?:        For bug reports, consult the following page on
  12. ;                the World Wide Web:
  13. ;
  14. ;                    http://developer.apple.com/bugreporter/
  15. ;
  16. ;
  17.     IF &TYPE('__OSUTILS__') = 'UNDEFINED' THEN
  18. __OSUTILS__ SET 1
  19.  
  20.     IF &TYPE('__MACTYPES__') = 'UNDEFINED' THEN
  21.     include 'MacTypes.a'
  22.     ENDIF
  23.     IF &TYPE('__MIXEDMODE__') = 'UNDEFINED' THEN
  24.     include 'MixedMode.a'
  25.     ENDIF
  26. ;   HandToHand and other memory utilties were moved to MacMemory.h 
  27.     IF &TYPE('__MACMEMORY__') = 'UNDEFINED' THEN
  28.     include 'MacMemory.a'
  29.     ENDIF
  30. ;   GetTrapAddress and other trap table utilties were moved to Patches.h 
  31.     IF &TYPE('__PATCHES__') = 'UNDEFINED' THEN
  32.     include 'Patches.a'
  33.     ENDIF
  34. ;   Date and Time utilties were moved to DateTimeUtils.h 
  35.     IF &TYPE('__DATETIMEUTILS__') = 'UNDEFINED' THEN
  36.     include 'DateTimeUtils.a'
  37.     ENDIF
  38.     IF ¬ TARGET_OS_MAC THEN
  39.     IF &TYPE('__ENDIAN__') = 'UNDEFINED' THEN
  40.     include 'Endian.a'
  41.     ENDIF
  42.     ENDIF
  43.  
  44. useFree                            EQU        0
  45. useATalk                        EQU        1
  46. useAsync                        EQU        2
  47. useExtClk                        EQU        3                    ;Externally clocked
  48. useMIDI                            EQU        4
  49.  
  50. false32b                        EQU        0                    ;24 bit addressing error
  51. true32b                            EQU        1                    ;32 bit addressing error
  52.  
  53.                                                             ; result types for RelString Call 
  54. sortsBefore                        EQU        -1                    ;first string < second string
  55. sortsEqual                        EQU        0                    ;first string = second string
  56. sortsAfter                        EQU        1                    ;first string > second string
  57.  
  58. dummyType                        EQU        0
  59. vType                            EQU        1
  60. ioQType                            EQU        2
  61. drvQType                        EQU        3
  62. evType                            EQU        4
  63. fsQType                            EQU        5
  64. sIQType                            EQU        6
  65. dtQType                            EQU        7
  66. nmType                            EQU        8
  67. ; typedef SignedByte                     QTypes
  68.  
  69. SysParmType                RECORD 0
  70. valid                     ds.b    1                ; offset: $0 (0)
  71. aTalkA                     ds.b    1                ; offset: $1 (1)
  72. aTalkB                     ds.b    1                ; offset: $2 (2)
  73. config                     ds.b    1                ; offset: $3 (3)
  74. portA                     ds.w    1                ; offset: $4 (4)
  75. portB                     ds.w    1                ; offset: $6 (6)
  76. alarm                     ds.l    1                ; offset: $8 (8)
  77. font                     ds.w    1                ; offset: $C (12)
  78. kbdPrint                 ds.w    1                ; offset: $E (14)
  79. volClik                     ds.w    1                ; offset: $10 (16)
  80. misc                     ds.w    1                ; offset: $12 (18)
  81. sizeof                     EQU *                    ; size:   $14 (20)
  82.                         ENDR
  83. ; typedef struct SysParmType *            SysPPtr
  84.  
  85. QElem                    RECORD 0
  86. qLink                     ds.l    1                ; offset: $0 (0)
  87. qType                     ds.w    1                ; offset: $4 (4)
  88. qData                     ds.w    1                ; offset: $6 (6) <-- really an array of length one
  89. sizeof                     EQU *                    ; size:   $8 (8)
  90.                         ENDR
  91. ; typedef struct QElem *                QElemPtr
  92.  
  93.     IF TARGET_OS_MAC THEN
  94. QHdr                    RECORD 0
  95. qFlags                     ds.w    1                ; offset: $0 (0)
  96. qHead                     ds.l    1                ; offset: $2 (2)
  97. qTail                     ds.l    1                ; offset: $6 (6)
  98. sizeof                     EQU *                    ; size:   $A (10)
  99.                         ENDR
  100. ; typedef struct QHdr *                    QHdrPtr
  101.  
  102.     ELSE
  103.  
  104. ;   QuickTime 3.0:
  105. ;   this version of QHdr contains the Mutex necessary for
  106. ;   non-mac non-interrupt code
  107.  
  108.  
  109. QHdr                    RECORD 0
  110. qFlags                     ds.w    1                ; offset: $0 (0)
  111. pad                         ds.w    1                ; offset: $2 (2)
  112. MutexID                     ds.l    1                ; offset: $4 (4)
  113. qHead                     ds.l    1                ; offset: $8 (8)
  114. qTail                     ds.l    1                ; offset: $C (12)
  115. sizeof                     EQU *                    ; size:   $10 (16)
  116.                         ENDR
  117. ; typedef struct QHdr *                    QHdrPtr
  118.  
  119.     ENDIF    ; TARGET_OS_MAC
  120.  
  121.  
  122. DeferredTask            RECORD 0
  123. qLink                     ds.l    1                ; offset: $0 (0)
  124. qType                     ds.w    1                ; offset: $4 (4)
  125. dtFlags                     ds.w    1                ; offset: $6 (6)
  126. dtAddr                     ds.l    1                ; offset: $8 (8)
  127. dtParam                     ds.l    1                ; offset: $C (12)
  128. dtReserved                 ds.l    1                ; offset: $10 (16)
  129. sizeof                     EQU *                    ; size:   $14 (20)
  130.                         ENDR
  131. ; typedef struct DeferredTask *            DeferredTaskPtr
  132.  
  133.     IF TARGET_OS_MAC THEN
  134. MachineLocation            RECORD 0
  135. latitude                 ds.l    1                ; offset: $0 (0)
  136. longitude                 ds.l    1                ; offset: $4 (4)
  137. dlsDelta                 ds.b    1                ; offset: $8 (8)        ;  signed byte; daylight savings delta 
  138.                          ORG 8
  139. gmtDelta                 ds.l    1                ; offset: $8 (8)        ;  use low 24-bits only 
  140. sizeof                     EQU *                    ; size:   $C (12)
  141.                         ENDR
  142.     ELSE
  143. ;    QuickTime 3.0:
  144. ;    Alignment of MachineLocation is weird. The union above used for delta
  145. ;    tends not to work on non-Mac compilers.
  146. ;
  147.  
  148. MachineLocation            RECORD 0
  149. latitude                 ds.l    1                ; offset: $0 (0)
  150. longitude                 ds.l    1                ; offset: $4 (4)
  151. delta                     ds        BigEndianLong    ; offset: $8 (8)        ;  high byte is daylight savings delta, low 24-bits is GMT delta 
  152. sizeof                     EQU *                    ; size:   $C (12)
  153.                         ENDR
  154.     ENDIF    ; TARGET_OS_MAC
  155. ;
  156. ; pascal Boolean IsMetric(void )
  157. ;
  158.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  159.         Macro
  160.         _IsMetric
  161.             move.w              #$0004,-(sp)
  162.             dc.w                $A9ED
  163.         EndM
  164.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  165.         IMPORT_CFM_FUNCTION IsMetric
  166.     ENDIF
  167.  
  168. ;
  169. ; pascal SysPPtr GetSysPPtr(void )
  170. ;
  171.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  172.         Macro
  173.         _GetSysPPtr           &dest=(sp)
  174.             move.l            #$000001F8,&dest
  175.         EndM
  176.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  177.         IMPORT_CFM_FUNCTION GetSysPPtr
  178.     ENDIF
  179.  
  180.  
  181. ;    NOTE: SysBeep() has been moved to Sound.h.  
  182. ;          We could not automatically #include Sound.h in this file
  183. ;          because Sound.h indirectly #include's OSUtils.h which
  184. ;          would make a circular include.
  185. ;
  186.  
  187. ;
  188. ; pascal OSErr DTInstall(DeferredTaskPtr dtTaskPtr)
  189. ;
  190.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  191.         ; parameters:
  192.         ;    dtTaskPtr       => A0
  193.         ; returns:
  194.         ;    OSErr           <= D0
  195.         _DTInstall:    OPWORD    $A082
  196.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  197.         IMPORT_CFM_FUNCTION DTInstall
  198.     ENDIF
  199.  
  200.  
  201.  
  202. ;
  203. ; pascal SInt8 GetMMUMode(void)
  204. ;
  205.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  206.         Macro
  207.         _GetMMUMode           &dest=(sp)
  208.             move.b            $0CB2,&dest
  209.         EndM
  210.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  211.         IMPORT_CFM_FUNCTION GetMMUMode
  212.     ENDIF
  213.  
  214. ;
  215. ; pascal SInt8 SwapMMUMode(SInt8 mode)
  216. ;
  217.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  218.         ; parameters:
  219.         ;    mode            => D0
  220.         ; returns:
  221.         ;    SInt8           <= D0
  222.         _SwapMMUMode:    OPWORD    $A05D
  223.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  224.         IMPORT_CFM_FUNCTION SwapMMUMode
  225.     ENDIF
  226.  
  227. ;
  228. ; pascal void Delay(unsigned long numTicks, unsigned long *finalTicks)
  229. ;
  230.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  231.         _Delay:    OPWORD    $A03B
  232.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  233.         IMPORT_CFM_FUNCTION Delay
  234.     ENDIF
  235.  
  236.  
  237. ;
  238. ; pascal OSErr WriteParam(void )
  239. ;
  240.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  241.         _WriteParam:    OPWORD    $A038
  242.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  243.         IMPORT_CFM_FUNCTION WriteParam
  244.     ENDIF
  245.  
  246. ;
  247. ; pascal void Enqueue(QElemPtr qElement, QHdrPtr qHeader)
  248. ;
  249.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  250.         ; parameters:
  251.         ;    qElement        => A0
  252.         ;    qHeader         => A1
  253.         _Enqueue:    OPWORD    $A96F
  254.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  255.         IMPORT_CFM_FUNCTION Enqueue
  256.     ENDIF
  257.  
  258. ;
  259. ; pascal OSErr Dequeue(QElemPtr qElement, QHdrPtr qHeader)
  260. ;
  261.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  262.         ; parameters:
  263.         ;    qElement        => A0
  264.         ;    qHeader         => A1
  265.         ; returns:
  266.         ;    OSErr           <= D0
  267.         _Dequeue:    OPWORD    $A96E
  268.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  269.         IMPORT_CFM_FUNCTION Dequeue
  270.     ENDIF
  271.  
  272. ;
  273. ; pascal OSErr InitUtil(void )
  274. ;
  275.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  276.         ; returns:
  277.         ;    OSErr           <= D0
  278.         _InitUtil:    OPWORD    $A03F
  279.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  280.         IMPORT_CFM_FUNCTION InitUtil
  281.     ENDIF
  282.  
  283.  
  284.     IF TARGET_CPU_PPC THEN
  285. ;
  286. ; pascal void MakeDataExecutable(void *baseAddress, unsigned long length)
  287. ;
  288.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  289.         IMPORT_CFM_FUNCTION MakeDataExecutable
  290.     ENDIF
  291.  
  292.     ENDIF    ; TARGET_CPU_PPC
  293.     IF TARGET_CPU_68K THEN
  294. ;
  295. ; pascal Boolean SwapInstructionCache(Boolean cacheEnable)
  296. ;
  297.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  298.         Macro
  299.         _SwapInstructionCache
  300.             moveq               #0,D0
  301.             dc.w                $A098
  302.         EndM
  303.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  304.         IMPORT_CFM_FUNCTION SwapInstructionCache
  305.     ENDIF
  306.  
  307. ;
  308. ; pascal void FlushInstructionCache(void )
  309. ;
  310.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  311.         Macro
  312.         _FlushInstructionCache
  313.             moveq               #1,D0
  314.             dc.w                $A098
  315.         EndM
  316.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  317.         IMPORT_CFM_FUNCTION FlushInstructionCache
  318.     ENDIF
  319.  
  320. ;
  321. ; pascal Boolean SwapDataCache(Boolean cacheEnable)
  322. ;
  323.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  324.         Macro
  325.         _SwapDataCache
  326.             moveq               #2,D0
  327.             dc.w                $A098
  328.         EndM
  329.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  330.         IMPORT_CFM_FUNCTION SwapDataCache
  331.     ENDIF
  332.  
  333. ;
  334. ; pascal void FlushDataCache(void )
  335. ;
  336.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  337.         Macro
  338.         _FlushDataCache
  339.             moveq               #3,D0
  340.             dc.w                $A098
  341.         EndM
  342.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  343.         IMPORT_CFM_FUNCTION FlushDataCache
  344.     ENDIF
  345.  
  346. ;
  347. ; pascal void FlushCodeCache(void )
  348. ;
  349.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  350.         _FlushCodeCache:    OPWORD    $A0BD
  351.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  352.         IMPORT_CFM_FUNCTION FlushCodeCache
  353.     ENDIF
  354.  
  355. ;
  356. ; pascal void FlushExternalCache(void )
  357. ;
  358.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  359.         Macro
  360.         _FlushExternalCache
  361.             moveq               #6,D0
  362.             dc.w                $A098
  363.         EndM
  364.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  365.         IMPORT_CFM_FUNCTION FlushExternalCache
  366.     ENDIF
  367.  
  368.     ENDIF    ; TARGET_CPU_68K
  369. ;
  370. ; pascal OSErr FlushCodeCacheRange(void *address, unsigned long count)
  371. ;
  372.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  373.         ; parameters:
  374.         ;    address         => A0
  375.         ;    count           => A1
  376.         ; returns:
  377.         ;    OSErr           <= D0
  378.         Macro
  379.         _FlushCodeCacheRange
  380.             moveq               #9,D0
  381.             dc.w                $A098
  382.         EndM
  383.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  384.         IMPORT_CFM_FUNCTION FlushCodeCacheRange
  385.     ENDIF
  386.  
  387. ;
  388. ; pascal void ReadLocation(MachineLocation *loc)
  389. ;
  390.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  391.         ; parameters:
  392.         ;    loc             => A0
  393.         Macro
  394.         _ReadLocation
  395.             move.l              #$000C00E4,D0
  396.             dc.w                $A051
  397.         EndM
  398.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  399.         IMPORT_CFM_FUNCTION ReadLocation
  400.     ENDIF
  401.  
  402.  
  403. ;
  404. ; pascal void WriteLocation(const MachineLocation *loc)
  405. ;
  406.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  407.         ; parameters:
  408.         ;    loc             => A0
  409.         Macro
  410.         _WriteLocation
  411.             move.l              #$000C00E4,D0
  412.             dc.w                $A052
  413.         EndM
  414.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  415.         IMPORT_CFM_FUNCTION WriteLocation
  416.     ENDIF
  417.  
  418.  
  419.  
  420.     IF OLDROUTINENAMES THEN
  421.     ENDIF    ; OLDROUTINENAMES
  422. ;    NOTE: SysEnvirons is obsolete.  You should be using Gestalt.
  423. ;
  424.  
  425. ;  Environs Equates 
  426.  
  427. curSysEnvVers                    EQU        2                    ;Updated to equal latest SysEnvirons version
  428. SysEnvRec                RECORD 0
  429. environsVersion             ds.w    1                ; offset: $0 (0)
  430. machineType                 ds.w    1                ; offset: $2 (2)
  431. systemVersion             ds.w    1                ; offset: $4 (4)
  432. processor                 ds.w    1                ; offset: $6 (6)
  433. hasFPU                     ds.b    1                ; offset: $8 (8)
  434. hasColorQD                 ds.b    1                ; offset: $9 (9)
  435. keyBoardType             ds.w    1                ; offset: $A (10)
  436. atDrvrVersNum             ds.w    1                ; offset: $C (12)
  437. sysVRefNum                 ds.w    1                ; offset: $E (14)
  438. sizeof                     EQU *                    ; size:   $10 (16)
  439.                         ENDR
  440.  
  441.                                                             ; Machine Types 
  442. envMac                            EQU        -1
  443. envXL                            EQU        -2
  444. envMachUnknown                    EQU        0
  445. env512KE                        EQU        1
  446. envMacPlus                        EQU        2
  447. envSE                            EQU        3
  448. envMacII                        EQU        4
  449. envMacIIx                        EQU        5
  450. envMacIIcx                        EQU        6
  451. envSE30                            EQU        7
  452. envPortable                        EQU        8
  453. envMacIIci                        EQU        9
  454. envMacIIfx                        EQU        11
  455.  
  456.                                                             ; CPU types 
  457. envCPUUnknown                    EQU        0
  458. env68000                        EQU        1
  459. env68010                        EQU        2
  460. env68020                        EQU        3
  461. env68030                        EQU        4
  462. env68040                        EQU        5
  463.  
  464.                                                             ; Keyboard types 
  465. envUnknownKbd                    EQU        0
  466. envMacKbd                        EQU        1
  467. envMacAndPad                    EQU        2
  468. envMacPlusKbd                    EQU        3
  469. envAExtendKbd                    EQU        4
  470. envStandADBKbd                    EQU        5
  471. envPrtblADBKbd                    EQU        6
  472. envPrtblISOKbd                    EQU        7
  473. envStdISOADBKbd                    EQU        8
  474. envExtISOADBKbd                    EQU        9
  475. ;
  476. ; pascal OSErr SysEnvirons(short versionRequested, SysEnvRec *theWorld)
  477. ;
  478.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  479.         ; parameters:
  480.         ;    versionRequetheWorld=> D0
  481.         ;    theWorld        => A0
  482.         ; returns:
  483.         ;    OSErr           <= D0
  484.         _SysEnvirons:    OPWORD    $A090
  485.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  486.         IMPORT_CFM_FUNCTION SysEnvirons
  487.     ENDIF
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.     ENDIF ; __OSUTILS__ 
  495.  
  496.